<template>
   <div>
      <div class="banner" @click="handleBannerClick">
        <img class="banner-img" :src="bannerImage" alt="">
        <div class="banner-info">
            <div class="banner-number"><span class="iconfont">&#xe653;</span>{{this.galleryImages.length}}</div>
            <div class="banner-title">{{this.sightName}}</div>
        </div>
      </div>
      <common-Fade>
         <Common-Gallery :imgsList="galleryImages" v-show="isGalleryShow" @closeGallery="handleGalleryClose"></Common-Gallery>
      </common-Fade>
   </div>
</template>

<script>
import CommonGallery from 'common/gallery/Gallery' // common路径已在build/webpack.base.conf.js中配置
import Fade from 'common/fade/Fade'
export default {
  name: 'CityDetail',
  props: {
    sightName: String,
    bannerImage: String,
    galleryImages: Array
  },
  data: function () {
    return {
      isGalleryShow: false
    }
  },
  components: {
    'CommonGallery': CommonGallery,
    'CommonFade': Fade
  },
  methods: {
    handleBannerClick: function () {
      this.isGalleryShow = true // 会改变swiper轮播widt，不能正常轮播
    },
    handleGalleryClose: function (val) {
      this.isGalleryShow = val
    }
  },
  mounted: function () {
    console.log(this.sightName)
  }
}
</script>

<style lang='stylus' scoped>
   .banner{
       position: relative;
       width: 100%;
       height: 0;
       padding-bottom: 55%;
       background-color: #eee; // 解决网速慢的问题
   }
   .banner .banner-img{
       width: 100%;
   }
   .banner .banner-info{
       position: absolute;
       bottom: 0;
       right: 0;
       left: 0;
       line-height: .6rem;
       padding: 0 .2rem .2rem;
       color: #fff;
       background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .8))
   }
   .banner .banner-info .banner-number{
       width: 1.2rem;
       height: .4rem;
       line-height: .4rem;
       text-align: center;
       background-color: rgba(0, 0, 0, .5); // 解决外面盒子透明 里面盒子不透明
       border-radius: .2rem;
       font-size: .24rem;
   }
   .banner .banner-info .banner-title{
       width: 100%;
       height: .6rem;
       line-height: .6rem;
       font-size: .36rem;
   }
</style>
